package com.taobao.demo.user.exception;

import com.taobao.demo.user.common.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 类描述：
 * 
 * @author xhy
 * @date 2025/10/19 18:14
 * @version 1.0.0
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(UserAuthException.class)
    public Result<Void> handleAuthException(UserAuthException e) {
        return Result.fail(e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public Result<Void> handleGlobalException(Exception e) {
        e.printStackTrace(); // 生产环境建议用日志框架
        return Result.fail("系统异常，请稍后再试");
    }
}
